//import java.util.Arrays;
//import java.util.Date;
import demo.TestDemo;

import java.util.*;
//import java.sql.*;





class Student {
    private String name;
    private String stuNumber;
    private int age;

    public static String classNumber = "1班";//班级

    @Override
    public String toString() {
        return "Student{" +
                "姓名='" + name + '\'' +
                ", 学号='" + stuNumber + '\'' +
                ", 年龄=" + age +
                '}';
    }

    public Student() {
        System.out.println("无参数的构造方法被调用了");
    }
    //实例代码块，创建对象是被执行。
    {
        this.name = "lisi";
        this.age = 15;
        this.stuNumber = "213154";
        System.out.println("实例代码块被执行了");
    }

    //当类被加载的时候被执行
    //静态代码块，定义在类的里面，方法的外面。
    static {
        classNumber = "2班";
        System.out.println("静态代码块被执行了");
    }



    public Student(String name, String stuNumber, int age) {
        this.name = name;
        this.stuNumber = stuNumber;
        this.age = age;
    }
    public static String getClassNumber() {
        //name = "lisi";//会报错，静态方法不能访问普通成员变量。
        return classNumber;
    }
    public void eat() {
        System.out.println(this.name+"正在吃饭");
    }

    public void show() {
        System.out.println("名字"+this.name+" 学号"+this.stuNumber+" 年龄"+this.age+" 班级"+classNumber);
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getName() {
        return this.name;
    }

    public String getStuNumber() {
        return stuNumber;
    }

    public void setStuNumber(String stuNumber) {
        this.stuNumber = stuNumber;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
public class Test2 {
    public static void main(String[] args) {
        Student student =new Student();
        System.out.println(student);
    }
    public static void main7(String[] args) {
        Student student1 = new Student();
        System.out.println("=========");
        Student student2 = new Student();
        //System.out.println(Student.getClassNumber());
    }
    public static void main6(String[] args) {//从这

        {//从这
            int a = 10;
            System.out.println(a);
        }//到这，是一个代码块

        int b = 20;

//        if(b > 10) {//从这
//            System.out.println(b);
//        }//到这，是一个代码块

    }//到这，是一个代码块
    public static void main5(String[] args) {
        System.out.println(Student.getClassNumber());
        //System.out.println(Student.classNumber);
    }
    public static void main4(String[] args) {
        Student student1 = new Student("zhangsan","20241234",18);

        Student.classNumber = "1班";

        Student student2 = new Student("lisi","20244456",15);

        System.out.println(Student.classNumber);

        System.out.println(student1.classNumber);

        System.out.println(student2.classNumber);
//        student1.show();
//        student2.show();
    }
    public static void main3(String[] args) {
        TestDemo testDemo = new TestDemo();
        testDemo.a = 10;
//        testDemo.b = 20;
//        testDemo.c = 30;
    }
    public static void main2(String[] args) {
        int[] array = {1,2,3,4,5,6};
        String[] arrays = {"lisi","zhangsan","liming"};
        System.out.println(Arrays.toString(array));
        //System.out.println(java.util.Arrays.toString(array));
        //System.out.println(Arrays.toString(arrays));
//        Date date = new Date();
//        System.out.println(date.getTime());//获得一个毫秒的时间戳
    }
    public static void main1(String[] args) {
        Student student = new Student();
        //student.name = "lisi";//当成员变量被封装后，不能在类外调用，会报错
        student.setName("lisi");
        System.out.println(student.getName());
        student.setAge(15);
        System.out.println(student.getAge());
        student.setStuNumber("1234456");
        System.out.println(student.getStuNumber());
    }
}
